package com.ruoyi.app.controller.company;

import com.ruoyi.app.company.CompanyBusiness;
import com.ruoyi.app.config.annotation.OperationAuth;
import com.ruoyi.app.domain.company.CompanyDetail;
import com.ruoyi.app.domain.company.CompanySave;
import com.ruoyi.common.core.web.domain.APIResult;
import com.ruoyi.service.user.enums.UserTypeEnum;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 公司管理
 *
 * @author Zane
 * @since 2025-09-27
 */

@RestController
@RequestMapping("/company/")
public class CompanyController {

  @Resource
  private CompanyBusiness companyBusiness;

  /**
   * 项目方公司明细
   */
  @OperationAuth(UserTypeEnum.DEMANDER_USER)
  @PostMapping("myCompanyDetail")
  public APIResult<CompanyDetail> myCompanyDetail() {
    CompanyDetail companyInfo = companyBusiness.myCompanyDetail();
    return APIResult.success(companyInfo);
  }

  /**
   * 项目方公司信息修改
   */
  @OperationAuth(UserTypeEnum.DEMANDER_USER)
  @PostMapping("update")
  public APIResult<Void> update(@Validated @RequestBody CompanySave companySave) {
    companyBusiness.update(companySave);
    return APIResult.success();
  }
}
